<<<<<<< HEAD
import React, { useEffect, useState } from 'react'
import { HeartOutlined, EyeOutlined, ShareAltOutlined } from '@ant-design/icons';
import "../../../index.css"
import { useNavigate } from 'react-router-dom';
import axios from 'axios';
=======
import React from 'react'
import { HeartOutlined, EyeOutlined, ShareAltOutlined  } from '@ant-design/icons';
import "../../../index.css"
>>>>>>> wanghengda
type Props = {}

const Index = (props: Props) => {
    const navigate = useNavigate()
    const [index_list, setindex_list] = useState([])
    const [index_list_son, setindex_list_son] = useState([])

    useEffect(() => {
        axios.get("https://bjwz.bwie.com/wipi/api/article?page=1&pageSize=12&status=publish").then(res => {
            setindex_list(res.data.data);
            localStorage.setItem("index_list_son", JSON.stringify(res.data.data))
        })
        const aaa = JSON.parse(localStorage.getItem("index_list_son") as string)
        if (index_list.length) {
            index_list.forEach((item: any, index: number) => {
                if (index === 0) {
                    setindex_list_son(item)
                }
            })
        } else {
            aaa.forEach((item: any, index: number) => {
                if (index === 0) {
                    setindex_list_son(item)
                }
            })
        }
    }, [])

    console.log(index_list_son);

    return (
        <div className='index wrap'>
<<<<<<< HEAD
            {index_list_son.length ? index_list_son.map((item: any, index: number) => {
                return <div className="index_list" key={index} onClick={() => {
                    navigate(`/home/datils/${item.id}`)
                    localStorage.setItem("datils_obj", JSON.stringify(item))
                }}>
                    <div className="index_head" >
                        <h4 style={{ "display": "inline-block", "marginLeft": "3%" }}>
                            {item.title}
                        </h4>
                        <span style={{ "marginLeft": "18px", "color": "#ccc" }}>1天前&emsp;|&emsp; 前端</span>
                    </div>
                    <div className="index_main">
                        <div className="index_main_left">
                            <img src={item.cover} alt="" />

                        </div>
                        <div className="index_main_right">
                            <p>
                                <span>
                                    <HeartOutlined />&nbsp;{item.likes > 0 ? item.likes : 10}&nbsp;&nbsp;&nbsp;&nbsp;
                                </span>
                                <span>
                                    <EyeOutlined />&nbsp;{item.views}&nbsp;&nbsp;&nbsp;&nbsp;
                                </span>
                                <span>
                                    <ShareAltOutlined />&nbsp;Share
                                </span>
                            </p>
                        </div>
                    </div>
                </div>
            }) : "暂无数据"}

=======
            <div className="index_list">
                <div className="index_head">
                    <h2 style={{ "display": "inline-block", "marginLeft": "3%" }}>
                        vitepress 中文文档 🎉
                    </h2>
                    <span style={{ "marginLeft": "18px", "color": "#ccc" }}>1天前&emsp;|&emsp; 前端</span>
                </div>
                <div className="index_main">
                    <div className="index_main_left">
                        <img src="https://p9-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/c73dd8e449a241e688121cd8aec609c6~tplv-k3u1fbpfcp-zoom-crop-mark:3024:3024:3024:1702.awebp?" alt="" />

                    </div>
                    <div className="index_main_right">
                        <p>
                            <span>
                                <HeartOutlined />&nbsp;3&nbsp;&nbsp;&nbsp;&nbsp;
                            </span>
                            <span>
                                <EyeOutlined />&nbsp;152&nbsp;&nbsp;&nbsp;&nbsp;
                            </span>
                            <span>
                                <ShareAltOutlined />&nbsp;Share
                            </span>
                        </p>
                    </div>
                </div>
            </div>
            <div className="index_list">
                <div className="index_head">
                    <h2 style={{ "display": "inline-block", "marginLeft": "3%" }}>
                        react指北：你真的会用hooks吗-中篇
                    </h2>
                    <span style={{ "marginLeft": "18px", "color": "#ccc" }}>1天前&emsp;|&emsp; 前端</span>
                </div>
                <div className="index_main">
                    <div className="index_main_left">
                    <img src="https://p6-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/5e615baa464d46908bde8dbbcf33b367~tplv-k3u1fbpfcp-zoom-crop-mark:3024:3024:3024:1702.awebp?" alt="" />

                    </div>
                    <div className="index_main_right">
                        <p>
                            <span>
                                <HeartOutlined />&nbsp;3&nbsp;&nbsp;&nbsp;&nbsp;
                            </span>
                            <span>
                                <EyeOutlined />&nbsp;152&nbsp;&nbsp;&nbsp;&nbsp;
                            </span>
                            <span>
                            <ShareAltOutlined />&nbsp;Share
                            </span>
                        </p>
                    </div>
                </div>
            </div>
>>>>>>> wanghengda
        </div>

    )
}

export default Index